package com.bwie.controller;

import com.bwie.pojo.TbPolicy;
import com.bwie.service.TbPolicyService;
import com.bwie.utils.Result;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @projectName: server-2211a-red
 * @package: com.bwie.controller
 * @className: IndexController
 * @author: 杨珂
 * @description: TODO
 * @date: 2025/6/7 11:01
 * @version: 1.0
 */
@RestController
@RequestMapping("/packet/index")
public class IndexController {


    @Autowired
    TbPolicyService tbPolicyService;

    @PostMapping("/getPolicyList")
    public Result getPolicyList(@RequestBody PageInfoVo pageInfoVo) {
        return tbPolicyService.getPolicyList(pageInfoVo);
    }

    /**
     * @param typeId:
     * @return Result
     * @author :杨珂
     * @description 根据类型获取字典列表
     * @date 2025/6/9 10:27
     */
    @PostMapping("/getDictList/{typeId}")
    public Result getDictList(@PathVariable("typeId") Integer typeId) {
        return tbPolicyService.getDictList(typeId);
    }


    @GetMapping("/exportPacketList/{userId}")
    public void exportPacketList(@PathVariable("userId") Integer userId) {
        tbPolicyService.exportPacketList(userId);
    }

    @PostMapping("/onAddPolicy")
    public Result onAddPolicy(@RequestBody TbPolicy tbPolicy) {
        return tbPolicyService.onAddPolicy(tbPolicy);
    }

}
